package com.platform.api;

import com.platform.entity.*;
import com.platform.mapper.WeChatService;
import com.platform.util.ApiBaseAction;
import com.platform.util.result.ResponseCode;
import com.platform.util.result.ResponseUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/api/wechat")
public class WeChatController extends ApiBaseAction {

    @Autowired
    private WeChatService weChatService;

    /**
     * 解析用户手机号
     */
    @RequestMapping(value = "/decrypt",method = {RequestMethod.POST})
    public String decrypt(@RequestBody WeChatDecryptParamDTO param){
        String response = weChatService.decrypt(param);
        return response;
    }

    /**
     * 获取二维码接口
     */
    @RequestMapping(value = "/getQRcode",method = {RequestMethod.POST})
    public String getQRcode(@RequestBody InviteParamDTO param){
        String openid = param.getOpenid();
        if (openid == null || openid.equals(""))
            return ResponseUtil.setResult(ResponseCode.REQUEST_NOT);
        String response = weChatService.getQRcode(openid,param.getGoodId());
        return response;
    }

    /**
     * 绑定邀请人与被邀请人接口
     */
    @RequestMapping(value = "/createInvite",method = {RequestMethod.POST})
    public String createInvite(@RequestBody InviteParamVo param){

        String response = weChatService.createInvite(param);
        return response;
    }

    /**
     *保存酒店信息
     */
    @RequestMapping(value = "/saveHotel",method = {RequestMethod.POST})
    public String saveHotel(@RequestBody HotelVo hotelVo){
        String response = weChatService.saveHotel(hotelVo);
        return response;
    }



}
